﻿using System;
using System.Data;
using System.Collections.Generic;
using Gmis.Model;
using Gmis.IDAL;
using Gmis.DalFactory;
namespace Gmis.BLL
{
    /// <summary>
    /// PMember
    /// </summary>
    public partial class PMember
    {
        private readonly IPMember dal = DataAccess.CreatePMember();
        public PMember()
        { }
        #region  Method
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string sId)
        {
            return dal.Exists(sId);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Gmis.Model.PMember model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Gmis.Model.PMember model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(string sId)
        {

            return dal.Delete(sId);
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteList(string sIdlist)
        {
            return dal.DeleteList(sIdlist);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Gmis.Model.PMember GetModel(string sId)
        {

            return dal.GetModel(sId);
        }

     
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Gmis.Model.PMember> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Gmis.Model.PMember> DataTableToList(DataTable dt)
        {
            List<Gmis.Model.PMember> modelList = new List<Gmis.Model.PMember>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Gmis.Model.PMember model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Gmis.Model.PMember();
                    if (dt.Rows[n]["sId"] != null && dt.Rows[n]["sId"].ToString() != "")
                    {
                        model.sId = dt.Rows[n]["sId"].ToString();
                    }
                    if (dt.Rows[n]["sNumber"] != null && dt.Rows[n]["sNumber"].ToString() != "")
                    {
                        model.sNumber = dt.Rows[n]["sNumber"].ToString();
                    }
                    if (dt.Rows[n]["sName"] != null && dt.Rows[n]["sName"].ToString() != "")
                    {
                        model.sName = dt.Rows[n]["sName"].ToString();
                    }
                    if (dt.Rows[n]["sSex"] != null && dt.Rows[n]["sSex"].ToString() != "")
                    {
                        model.sSex = dt.Rows[n]["sSex"].ToString();
                    }
                    if (dt.Rows[n]["dBorn"] != null && dt.Rows[n]["dBorn"].ToString() != "")
                    {
                        model.dBorn = DateTime.Parse(dt.Rows[n]["dBorn"].ToString());
                    }
                    if (dt.Rows[n]["sMarry"] != null && dt.Rows[n]["sMarry"].ToString() != "")
                    {
                        model.sMarry = dt.Rows[n]["sMarry"].ToString();
                    }
                    if (dt.Rows[n]["sIdentity"] != null && dt.Rows[n]["sIdentity"].ToString() != "")
                    {
                        model.sIdentity = dt.Rows[n]["sIdentity"].ToString();
                    }
                    if (dt.Rows[n]["sNation"] != null && dt.Rows[n]["sNation"].ToString() != "")
                    {
                        model.sNation = dt.Rows[n]["sNation"].ToString();
                    }
                    if (dt.Rows[n]["sEducation"] != null && dt.Rows[n]["sEducation"].ToString() != "")
                    {
                        model.sEducation = dt.Rows[n]["sEducation"].ToString();
                    }
                    if (dt.Rows[n]["sWork"] != null && dt.Rows[n]["sWork"].ToString() != "")
                    {
                        model.sWork = dt.Rows[n]["sWork"].ToString();
                    }
                    if (dt.Rows[n]["sWorkPlace"] != null && dt.Rows[n]["sWorkPlace"].ToString() != "")
                    {
                        model.sWorkPlace = dt.Rows[n]["sWorkPlace"].ToString();
                    }
                    if (dt.Rows[n]["sPosition"] != null && dt.Rows[n]["sPosition"].ToString() != "")
                    {
                        model.sPosition = dt.Rows[n]["sPosition"].ToString();
                    }
                    if (dt.Rows[n]["nAge"] != null && dt.Rows[n]["nAge"].ToString() != "")
                    {
                        model.nAge = int.Parse(dt.Rows[n]["nAge"].ToString());
                    }
                    if (dt.Rows[n]["sNative"] != null && dt.Rows[n]["sNative"].ToString() != "")
                    {
                        model.sNative = dt.Rows[n]["sNative"].ToString();
                    }
                    if (dt.Rows[n]["dJoin"] != null && dt.Rows[n]["dJoin"].ToString() != "")
                    {
                        model.dJoin = DateTime.Parse(dt.Rows[n]["dJoin"].ToString());
                    }
                    if (dt.Rows[n]["sMobile"] != null && dt.Rows[n]["sMobile"].ToString() != "")
                    {
                        model.sMobile = dt.Rows[n]["sMobile"].ToString();
                    }
                    if (dt.Rows[n]["sAddress"] != null && dt.Rows[n]["sAddress"].ToString() != "")
                    {
                        model.sAddress = dt.Rows[n]["sAddress"].ToString();
                    }
                    if (dt.Rows[n]["sPicture"] != null && dt.Rows[n]["sPicture"].ToString() != "")
                    {
                        model.sPicture = dt.Rows[n]["sPicture"].ToString();
                    }
                    if (dt.Rows[n]["sCharge"] != null && dt.Rows[n]["sCharge"].ToString() != "")
                    {
                        model.sCharge = dt.Rows[n]["sCharge"].ToString();
                    }
                    if (dt.Rows[n]["sComment"] != null && dt.Rows[n]["sComment"].ToString() != "")
                    {
                        model.sComment = dt.Rows[n]["sComment"].ToString();
                    }
                    if (dt.Rows[n]["iPicture"] != null && dt.Rows[n]["iPicture"].ToString() != "")
                    {
                        model.iPicture = (byte[])dt.Rows[n]["iPicture"];
                    }
                    if (dt.Rows[n]["dInDate"] != null && dt.Rows[n]["dInDate"].ToString() != "")
                    {
                        model.dInDate = DateTime.Parse(dt.Rows[n]["dInDate"].ToString());
                    }
                    if (dt.Rows[n]["sInReason"] != null && dt.Rows[n]["sInReason"].ToString() != "")
                    {
                        model.sInReason = dt.Rows[n]["sInReason"].ToString();
                    }
                    if (dt.Rows[n]["sInPlace"] != null && dt.Rows[n]["sInPlace"].ToString() != "")
                    {
                        model.sInPlace = dt.Rows[n]["sInPlace"].ToString();
                    }
                    if (dt.Rows[n]["dOutDate"] != null && dt.Rows[n]["dOutDate"].ToString() != "")
                    {
                        model.dOutDate = DateTime.Parse(dt.Rows[n]["dOutDate"].ToString());
                    }
                    if (dt.Rows[n]["sOutReason"] != null && dt.Rows[n]["sOutReason"].ToString() != "")
                    {
                        model.sOutReason = dt.Rows[n]["sOutReason"].ToString();
                    }
                    if (dt.Rows[n]["sOutPlace"] != null && dt.Rows[n]["sOutPlace"].ToString() != "")
                    {
                        model.sOutPlace = dt.Rows[n]["sOutPlace"].ToString();
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  Method
    }
}

